const SkeletonWebpackPlugin = require('vue-skeleton-webpack-plugin')

const path = require('path')
const webpack = require('webpack')
// __dirname 表示的是项目的目录
function resolve(dir) {
    return path.join(__dirname, dir)
}
module.exports = {
    publicPath: process.env.NODE_ENV === "production" ? "/vue-cube-master-template" : "/",
    configureWebpack: (config) => {
        config.plugins.push(new SkeletonWebpackPlugin({
            webpackConfig: {
                entry: {
                    app: path.join(__dirname, './src/components/v-skeleton/skeleton.js')
                }
            },
            minimize: true,
            quiet: true
        }))
    },
    css: {
        // 是否使用css分离插件 ExtractTextPlugin
        extract: true,
        // 开启 CSS source maps?
        sourceMap: false,
        // 启用 CSS modules for all css / pre-processor files.
        modules: false,
        loaderOptions: {
            stylus: {
                'resolve url': true,
                'import': [
                    './src/theme'
                ]
            }
        }
    },
    pluginOptions: {
        'cube-ui': {
            postCompile: true,
            theme: true
        }
    },
    // 配置webpack目录别名
    chainWebpack(config) {
        config.resolve.alias
            .set('components', resolve('src/components'))
            .set('views', resolve('src/views'))
            .set('router', resolve('src/router'))
            .set('api', resolve('src/api'))
            .set('common', resolve('src/common'))
            .set('config', resolve('src/config'))
        config.plugin('context')
            .use(webpack.ContextReplacementPlugin,
                [/moment[\/\\]locale$/, /zh-cn/])
    }
}
